Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollout improved example converter #1064

Merged
merged 4 commits into from
Apr 18, 2024
Merged

Rollout improved example converter #1064

merged 4 commits into from
Apr 18, 2024

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Apr 16, 2024

Rolls out improved TF example converter.

Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Maintainer note: consult the runbook for dealing with any breaking changes.

Copy link

Is README.md missing any configuration options?

caMaterial not found in Configuration section
certMaterial not found in Configuration section
certPath not found in Configuration section
host not found in Configuration section
keyMaterial not found in Configuration section
registryAuth not found in Configuration section
sshOpts not found in Configuration section

Please add a description for each of these options to README.md. Details about them can be found in either the upstream docs or schema.json.

Copy link
Contributor

@blampe blampe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question around whether we expect to lose some examples but otherwise LGTM

@@ -3629,7 +3629,7 @@
}
},
"docker:index/registryImage:RegistryImage": {
"description": "\u003c!-- Bug: Type and Name are switched --\u003e\nManages the lifecycle of docker image in a registry. You can upload images to a registry (= `docker push`) and also delete them again\n\n## Example Usage\n\nBuild an image with the `docker.RemoteImage` resource and then push it to a registry:\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as docker from \"@pulumi/docker\";\n\nconst helloworld = new docker.RegistryImage(\"helloworld\", {keepRemotely: true});\nconst image = new docker.RemoteImage(\"image\", {\n name: \"registry.com/somename:1.0\",\n build: {\n context: `${path.cwd}/absolutePathToContextFolder`,\n },\n});\n```\n```python\nimport pulumi\nimport pulumi_docker as docker\n\nhelloworld = docker.RegistryImage(\"helloworld\", keep_remotely=True)\nimage = docker.RemoteImage(\"image\",\n name=\"registry.com/somename:1.0\",\n build=docker.RemoteImageBuildArgs(\n context=f\"{path['cwd']}/absolutePathToContextFolder\",\n ))\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Docker = Pulumi.Docker;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n var helloworld = new Docker.RegistryImage(\"helloworld\", new()\n {\n KeepRemotely = true,\n });\n\n var image = new Docker.RemoteImage(\"image\", new()\n {\n Name = \"registry.com/somename:1.0\",\n Build = new Docker.Inputs.RemoteImageBuildArgs\n {\n Context = $\"{path.Cwd}/absolutePathToContextFolder\",\n },\n });\n\n});\n```\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/pulumi/pulumi-docker/sdk/v4/go/docker\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := docker.NewRegistryImage(ctx, \"helloworld\", \u0026docker.RegistryImageArgs{\n\t\t\tKeepRemotely: pulumi.Bool(true),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = docker.NewRemoteImage(ctx, \"image\", \u0026docker.RemoteImageArgs{\n\t\t\tName: pulumi.String(\"registry.com/somename:1.0\"),\n\t\t\tBuild: \u0026docker.RemoteImageBuildArgs{\n\t\t\t\tContext: pulumi.String(fmt.Sprintf(\"%v/absolutePathToContextFolder\", path.Cwd)),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.docker.RegistryImage;\nimport com.pulumi.docker.RegistryImageArgs;\nimport com.pulumi.docker.RemoteImage;\nimport com.pulumi.docker.RemoteImageArgs;\nimport com.pulumi.docker.inputs.RemoteImageBuildArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n var helloworld = new RegistryImage(\"helloworld\", RegistryImageArgs.builder() \n .keepRemotely(true)\n .build());\n\n var image = new RemoteImage(\"image\", RemoteImageArgs.builder() \n .name(\"registry.com/somename:1.0\")\n .build(RemoteImageBuildArgs.builder()\n .context(String.format(\"%s/absolutePathToContextFolder\", path.cwd()))\n .build())\n .build());\n\n }\n}\n```\n```yaml\nresources:\n helloworld:\n type: docker:RegistryImage\n properties:\n keepRemotely: true\n image:\n type: docker:RemoteImage\n properties:\n name: registry.com/somename:1.0\n build:\n context: ${path.cwd}/absolutePathToContextFolder\n```\n\u003c!--End PulumiCodeChooser --\u003e\n",
"description": "\u003c!-- Bug: Type and Name are switched --\u003e\nManages the lifecycle of docker image in a registry. You can upload images to a registry (= `docker push`) and also delete them again\n\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@t0yv0 is it expected for some of these examples to be dropped? This seems like a step backward, but maybe they were just malformed or didn't convert cleanly?

@@ -34,3 +38,4 @@ actions:
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
pulumiConvert: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this file even exists -- I'm assuming it takes precedence over https://github.com/pulumi/ci-mgmt/blob/master/provider-ci/providers/docker/config.yaml? Ugh.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this file here is the source of truth, and if you run make ci-mgmt it resyncs derivative files to it.

@t0yv0
Copy link
Member Author

t0yv0 commented Apr 18, 2024

jq -r '.|select(.ExampleName=="#/resources/docker:index/registryImage:RegistryImage").OriginalHCL' cov/byExample.json                                                                                                                  ~/bugs/ci-mgmt-889/pulumi-docker
resource "docker_registry_image" "helloworld" {
  name          = docker_image.image.name
  keep_remotely = true
}

resource "docker_image" "image" {
  name = "registry.com/somename:1.0"
  build {
    context = "${path.cwd}/absolutePathToContextFolder"
  }
}
t0yv0@Antons-MacBook-Pro> jq -r '.|select(.ExampleName=="#/resources/docker:index/registryImage:RegistryImage")' cov/byExample.json                                                                                                                              ~/bugs/ci-mgmt-889/pulumi-docker
{
  "ExampleName": "#/resources/docker:index/registryImage:RegistryImage",
  "OriginalHCL": "resource \"docker_registry_image\" \"helloworld\" {\n  name          = docker_image.image.name\n  keep_remotely = true\n}\n\nresource \"docker_image\" \"image\" {\n  name = \"registry.com/somename:1.0\"\n  build {\n    context = \"${path.cwd}/absolutePathToContextFolder\"\n  }\n}\n",
  "ConversionResults": {
    "csharp": {
      "FailureSeverity": 2,
      "FailureInfo": "Terraform input not yet implemented: path",
      "Program": "",
      "TranslationCount": 1
    },
    "go": {
      "FailureSeverity": 2,
      "FailureInfo": "Terraform input not yet implemented: path",
      "Program": "",
      "TranslationCount": 1
    },
    "java": {
      "FailureSeverity": 2,
      "FailureInfo": "Terraform input not yet implemented: path",
      "Program": "",
      "TranslationCount": 1
    },
    "python": {
      "FailureSeverity": 2,
      "FailureInfo": "Terraform input not yet implemented: path",
      "Program": "",
      "TranslationCount": 1
    },
    "typescript": {
      "FailureSeverity": 2,
      "FailureInfo": "Terraform input not yet implemented: path",
      "Program": "",
      "TranslationCount": 1
    },
    "yaml": {
      "FailureSeverity": 2,
      "FailureInfo": "Terraform input not yet implemented: path",
      "Program": "",
      "TranslationCount": 1
    }
  }
}

@t0yv0
Copy link
Member Author

t0yv0 commented Apr 18, 2024

Regarding the one example it appears to be another instance of pulumi/pulumi-converter-terraform#141

@t0yv0 t0yv0 merged commit 9d0bb50 into master Apr 18, 2024
18 checks passed
@t0yv0 t0yv0 deleted the t0yv0/rollout-converter branch April 18, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants